#include "qae_qcolorwidget.h"
#include "qae_qansipalette.h"
#include <QtCore/QString>
#include <QtGui/QHBoxLayout>
#include <QtGui/QPushButton>
#include <QtGui/QScrollBar>
#include <QtGui/QVBoxLayout>


namespace QAnsiEditor {


QColorWidget::QColorWidget(QWidget *parent) :
    QWidget(parent)
{
    init();
}

QSize QColorWidget::sizeHint() const
{
    return QSize(160, 40);
}

bool QColorWidget::init()
{
    m_pAnsiPalette = new QAnsiPalette;
    connect(m_pAnsiPalette, SIGNAL(colorChanged(char)), this, SIGNAL(colorChanged(char)));

    m_pBlickButton = new QPushButton(QIcon(":/icons/blink.png"), tr("Blink"));
    m_pBlickButton->setCheckable(true);
    connect(m_pBlickButton, SIGNAL(toggled(bool)), this, SIGNAL(blinkToggled(bool)));
    m_pUnderlineButton = new QPushButton(QIcon(":/icons/underline.png"), tr("Underline"));
    m_pUnderlineButton->setCheckable(true);
    connect(m_pUnderlineButton, SIGNAL(toggled(bool)), this, SIGNAL(underlineToggled(bool)));

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->setMargin(4);
    mainLayout->setSpacing(4);
    QHBoxLayout *bottonLayout = new QHBoxLayout;
    bottonLayout->setMargin(0);
    bottonLayout->setSpacing(4);
    bottonLayout->addWidget(m_pBlickButton);
    bottonLayout->addWidget(m_pUnderlineButton);
    mainLayout->addWidget(m_pAnsiPalette);
    mainLayout->addLayout(bottonLayout);
    setLayout(mainLayout);

    return true;
}


}  // namespace QAnsiEditor
